﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ScriptEditor.Commands
{
    class Command_Glitch : Command
    {
        public float intensity
        {
            get
            {
                return float.TryParse(Value1, out float result) ? result : 1;
            }
            set
            {
                Value1 = value.ToString();
            }
        }
        public bool randomFrequency
        {
            get
            {
                return bool.TryParse(Value2, out bool result) ? result : false;
            }
            set
            {
                Value2 = value.ToString();
            }
        }
        public float frequency
        {
            get
            {
                return float.TryParse(Value3, out float result) ? result : 0.5f;
            }
            set
            {
                Value3 = value.ToString();
            }
        }
        public bool uvShift
        {
            get
            {
                return bool.TryParse(Value4, out bool result) ? result : true;
            }
            set
            {
                Value4 = value.ToString();
            }
        }
        public float shiftAmount
        {
            get
            {
                return float.TryParse(Value5, out float result) ? result : 1f;
            }
            set
            {
                Value5 = value.ToString();
            }
        }
        public bool screenShift
        {
            get
            {
                return bool.TryParse(Value6, out bool result) ? result : true;
            }
            set
            {
                Value6 = value.ToString();
            }
        }
        public bool colorShift
        {
            get
            {
                return bool.TryParse(Value7, out bool result) ? result : true;
            }
            set
            {
                Value7 = value.ToString();
            }
        }
        public Color tintColor
        {
            get
            {
                return new Color { r = byte.TryParse(Value8.Substring(0, 2), System.Globalization.NumberStyles.HexNumber, null, out byte result) ? result : (byte)0xFF, g = byte.TryParse(Value8.Substring(2, 2), System.Globalization.NumberStyles.HexNumber, null, out byte result2) ? result2 : (byte)0xFF, b = byte.TryParse(Value8.Substring(4, 2), System.Globalization.NumberStyles.HexNumber, null, out byte result3) ? result3 : (byte)0xFF };
            }
            set
            {
                Value8 = value.r.ToString("X") + value.g.ToString("X") + value.b.ToString("X");
            }
        }
        public bool burnColor
        {
            get
            {
                return bool.TryParse(Value9, out bool result) ? result : true;
            }
            set
            {
                Value9 = value.ToString();
            }
        }
        public bool dodgeColor
        {
            get
            {
                return bool.TryParse(Value10, out bool result) ? result : false;
            }
            set
            {
                Value10 = value.ToString();
            }
        }
        public Command_Glitch()
        {
            CommandType = COMMANDTYPE.Glitch;
            intensity = 1;
            randomFrequency = false;
            frequency = 0.5f;
            uvShift = true;
            shiftAmount = 1;
            screenShift = true;
            colorShift = true;
            tintColor = new Color { r = 255, g = 255, b = 255 };
            burnColor = true;
            dodgeColor = false;
            Wait = false;
        }
        public Command_Glitch(float Intensity, bool RandomFrequency, float Frequency, bool UvShift, float ShiftAmount, bool ScreenShift, bool ColorShift, Color TintColor, bool BurnColor, bool DodgeColor)
        {
            CommandType = COMMANDTYPE.Glitch;
            intensity = Intensity;
            randomFrequency = RandomFrequency;
            frequency = Frequency;
            uvShift = UvShift;
            shiftAmount = ShiftAmount;
            screenShift = ScreenShift;
            colorShift = ColorShift;
            tintColor = TintColor;
            burnColor = BurnColor;
            dodgeColor = DodgeColor;
            Wait = false;
        }
        public override string ToString()
        {
            return CommandType.ToString() + ":\n"+"崩坏特效";
        }
    }
}
